﻿//////////////////////////////////////////////////////////////////////////////////
//	DataTypes.cs
//	Managed Wiimote 3D Library
//	Written by JungHyun Kim and JungHo Kim
//	Visit http://w3dlib.codeplex.com/
//	for more information
//////////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections;
using System.Collections.Generic;

using WiimoteLib;

namespace Wiimote3DLibX
{
    class IRData
    {
        private List<IRSensor> mIrSensorList = new List<IRSensor>();

        public IRData(IRSensor[] irs)
        {
            foreach (IRSensor ir in irs)
            {
                if (ir.Found)
                    mIrSensorList.Add(ir);
            }
        }

        /// <summary>
        /// IR Count
        /// </summary>
        public int IRCount
        {
            get { return mIrSensorList.Count; }
        }

        public WiimoteLib.Point this[int index]
        {
            get { return mIrSensorList[index].RawPosition; }
        }
    }

    /// <summary>
    /// Point class for double 3D Positions (X, Y, Z)
    /// </summary>
    public class Point3A<T> : Object, ICloneable
    {
        /// <summary>
        /// X, Y, Z coordinates of this point
        /// </summary>
        private T Pointx, Pointy, Pointz;

        /// <summary>
        /// public Point X
        /// </summary>
        public T PointX
        {
            get
            {
                return Pointx;
            }
            set
            {
                Pointx = value;
            }
        }

        /// <summary>
        /// public Point Y
        /// </summary>
        public T PointY
        {
            get
            {
                return Pointy;
            }
            set
            {
                Pointy = value;
            }
        }

        /// <summary>
        /// public Point Z
        /// </summary>
        public T PointZ
        {
            get
            {
                return Pointz;
            }
            set
            {
                Pointz = value;
            }
        }

        /// <summary>
        /// Default constructor
        /// </summary>
        public Point3A()
        {
            //Run time init
        }

        /// <summary>
        /// 초기 좌표 셋팅 생성자
        /// </summary>
        /// <param name="xPoint">x 좌표</param>
        /// <param name="yPoint">y 좌표</param>
        /// <param name="zPoint">z 좌표</param>
        public Point3A(T xPoint, T yPoint, T zPoint)
        {
            PointX = xPoint;
            PointY = yPoint;
            PointZ = zPoint;
        }

        /// <summary>
        /// Convert to human-readable string
        /// </summary>
        /// <returns>A string that represents the point.</returns>
        public override string ToString()
        {
            return string.Format("{{X={0}, Y={1}, Z={2}}}", PointX, PointY, PointZ);
        }

        /// <summary>
        /// Object Clone Function
        /// </summary>
        /// <returns>Point3A 객체 반환.</returns>
        public Object Clone()
        {
            return new Point3A<T>(PointX, PointY, PointZ);
        }

    }
}